// ImmKpRemoteClient.h: interface for the ImmKpRemoteClient class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_IMMKPREMOTECLIENT_H__C6BDDA00_AEA7_11D5_AC47_0080C84E291C__INCLUDED_)
#define AFX_IMMKPREMOTECLIENT_H__C6BDDA00_AEA7_11D5_AC47_0080C84E291C__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <windows.h>
#include "ImmKpFileInfo.h"
#include "ImmKpDataBuffer.h"

typedef char     far * LPSTR     ;
typedef LPSTR    far * LPLPSTR   ;

#define  FILE_COMMAND  1
#define VALUE_COMMAND  2
#define  STOP_COMMAND  4
#define  QUIT_COMMAND  8
#define  ZOOM_COMMAND 16
#define  SIZE_COMMAND 32
#define  COMPRESSION_COMMAND 64
#define  BOUNDS_COMMAND 128

#define	DEFAULT_HOST_NAME	"127.0.0.1"
#define	DEFAULT_PORT_NUMBER 1701

#define SERVER_CFG_FILE  "server.cfg"

class ImmKpRemoteClient  
{
public:
	void getHelloMessage(char *b);
	int getPortNumber();
	char* getServerName();
	ImmKpDataBuffer* mainDataStorage;
	ImmKpFileInfo* pfileInfo;
	void readServerDataFromFile(char *cfg_server = SERVER_CFG_FILE);
	void saveServerDataFromFile(char *cfg_server = SERVER_CFG_FILE);
	void setServerData(char *serverName, int serverPort);
	int CloseServerConnection();
	int ShutdownServer();
	int OpenServerConnection();
	int ProcessValue(float value, BOOL bZoom);
	/*int ProcessFile();*/
	int ProcessFileAndValue(float value, int cMethod, float cParams, BOOL bZoom);
	int ProcessAllRequests(char bCommand);
	int GetFileInfo_(ImmKpFileInfo *bfileInfo);
	int Create();
	ImmKpRemoteClient();
	virtual ~ImmKpRemoteClient();
private:
	BOOL bFileNameSet;		// server already knows this name
	BOOL bValueSet;			// server already knows this value
	char HOST_NAME[1024];
	int  PORT_NUMBER;
	int GetFileInfo(ImmKpFileInfo *bfileInfo);
	int sendFloat(int sock, float f);
	int sendInt(int sock, int i);
	int   getInt(int);
	float getFloat(int);
	void recv_pool(int sock, char *lppool, int cbExpected);

	SOCKET sock;

	BOOL bInitOK;
	WSADATA WSAData;	

	char serverHELLO[1024];
protected:
	char errorMessage[1024];
};

#endif // !defined(AFX_IMMKPREMOTECLIENT_H__C6BDDA00_AEA7_11D5_AC47_0080C84E291C__INCLUDED_)
